package com.huawei.hms.framework.network.grs.c;

import android.content.Context;
import android.os.Build;
import android.os.Build.VERSION;
import com.huawei.hms.framework.common.Logger;
import java.util.Locale;

public class a {
    private static String a = null;

    public static String a() {
        return "1.0.13.301";
    }

    public static String a(Context context) {
        if (context == null) {
            return "";
        }
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (Throwable e) {
            Logger.w("AgentUtil", "", e);
            return "";
        }
    }

    public static String a(Context context, String str) {
        if (context == null) {
            return String.format(Locale.ROOT, str + "/%s", new Object[]{a()});
        }
        String packageName = context.getPackageName();
        String a = a(context);
        String str2 = VERSION.RELEASE;
        String str3 = Build.MODEL;
        return String.format(Locale.ROOT, "%s/%s (Linux; Android %s; %s) " + str + "/%s", new Object[]{packageName, a, str2, str3, a()});
    }

    public static String b(Context context, String str) {
        if (a == null) {
            a = a(context, str);
        }
        return a;
    }
}
